package com.phpxiu.app.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import com.phpxiu.app.kkylive.R;

/**
 * Created by 吴金洲 on 2016/9/7
 */
public class SexMenus extends Dialog implements View.OnClickListener {

    private OnSexSelectedCallback callback;
    public SexMenus(Context context) {
        super(context, R.style.menusDialog);
        init(context);
    }

    private void init(Context context) {
        setContentView(R.layout.sex_menus);
        findViewById(R.id.base_view).setOnClickListener(this);
        findViewById(R.id.male).setOnClickListener(this);
        findViewById(R.id.female).setOnClickListener(this);
        findViewById(R.id.close_menu).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.close_menu:
            case R.id.base_view:
                break;
            case R.id.female:
                if (callback != null) {
                    callback.onSexSelected("0");
                }
                break;
            case R.id.male:
                if (callback != null) {
                    callback.onSexSelected("1");
                }
                break;
            default:
                break;
        }
        dismiss();
    }

    public void setCallback(OnSexSelectedCallback callback) {
        this.callback = callback;
    }

    /**
     * 性别选择接口
     */
    public interface OnSexSelectedCallback {
        void onSexSelected(String sex);
    }
}
